package com.ruoyi.aitcommon.service;

import java.lang.Thread.State;

import org.springframework.stereotype.Service;

import com.ruoyi.aitcommon.anotation.ServiceLog;
import com.ruoyi.aitcommon.utils.LogUtils;

import cn.hutool.core.thread.ThreadUtil;

/**
 * AIT运行状态查看
 * @author Administrator
 *
 */
@Service
public class AitSysService {
	/**
	 * 输出当前环境的运行状态
	 */
	@ServiceLog("ait运行状态")
	public void aitStatus() {
//		检查线程状态
		Thread[] threads = ThreadUtil.getThreads();
		int seq=0;
		System.out.println("=========ait线程状态===========");
		for(Thread thread:threads) {
			seq++;
			String msg="%s: 线程名称:%s,线程状态:%s";
			msg=String.format(msg, seq,thread.getName(),thread.getState());
			System.out.println(msg);
			if(thread.getState()==State.BLOCKED) {
				LogUtils.error(msg);
			}
		}
	}
}
